/*
 * TepcoMeter:WattDto.java
 * Copyright © 2011 ho9ho9 All Rights Reserved.
 */
package com.ho9ho9.tepcometer.dto;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * WattDtoクラス.
 * @author ho9ho9
 */
public class WattDto implements Cloneable {
	/** 0-23 時までの消費電力（万 kw）. */
	private List<HourDto> hours;
	/** ピーク時供給量（万 kw）. */
	private Integer capability;
	/** 更新日時. */
	private Date updated;
	/** 該当日. */
	private Date wattDay;
	/** DB挿入日. */
	private Date insertDate;
	
	public Date getInsertDate() {
		return insertDate;
	}
	public void setInsertDate(Date insertDate) {
		this.insertDate = insertDate;
	}
	public Date getWattDay() {
		return wattDay;
	}
	public void setWattDay(Date wattDay) {
		this.wattDay = wattDay;
	}
	public List<HourDto> getHours() {
		return hours;
	}
	public void setHours(List<HourDto> hourDtos) {
		this.hours = hourDtos;
	}
	public Integer getCapability() {
		return capability;
	}
	public void setCapability(Integer capability) {
		this.capability = capability;
	}
	public Date getUpdated() {
		return updated;
	}
	public void setUpdated(Date updated) {
		this.updated = updated;
	}
	public HourDto getCurrentHour() {
		HourDto result = null;
		for (HourDto h : this.hours) {
			if (h.getWattValue() == 0) {
				break;
			}
			result = h;
		}
		return result;
	}
	
	@SuppressWarnings("unchecked")
	public Object clone() {
		WattDto result = new WattDto();
		result.setCapability(capability);
		result.setWattDay(wattDay);
		result.setUpdated(updated);
		result.setInsertDate(insertDate);
		result.setHours((List<HourDto>)((ArrayList<HourDto>)hours).clone());
		return result;
	}
	
	/**
	 * {@inheritdoc}
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("capability=").append(capability);
		sb.append(",wattDay=").append(wattDay);
		sb.append(",updated=").append(updated);
		sb.append(",hours=").append(hours);
		sb.append(",insertDate=").append(insertDate);
		return sb.toString();
	}
}
